package com.game.forestfire.core;


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 * 最简可运行示例：Hello JavaFX 17
 * mvn javafx:run
 */
public class App extends Application {

    @Override
    public void start(Stage stage) {
        Label label = new Label("Hello JavaFX 17");
        label.setStyle("-fx-font-size: 40px; -fx-text-fill: red;");

        // 鼠标拖动时随机换色
        label.setOnMouseDragged(e -> label.setStyle(
                "-fx-font-size: 40px; -fx-text-fill: " + randomColor() + ";"));

        StackPane root = new StackPane(label);
        Scene scene = new Scene(root, 400, 300);

        stage.setTitle("Hello FX 17");
        stage.setScene(scene);
        stage.show();
    }

    private String randomColor() {
        return String.format("#%06X", (int) (Math.random() * 0xFFFFFF));
    }

    // 保留经典 main，兼容非模块运行
    public static void main(String[] args) {
        launch(args);
    }
}